<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <title>发票识别</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <div class="container">
        <h1>上传发票文件</h1>
        
        <!-- 错误提示 -->
        {% if error %}
            <div class="alert error">{{ error }}</div>
        {% endif %}
        
        <!-- 上传表单 -->
        <form method="post" enctype="multipart/form-data" action="/upload">
            <input type="file" name="file" accept=".pdf,.jpg,.png">
            <button type="submit">提交</button>
        </form>
        
        <!-- 识别结果 -->
        {% if result %}
            <div class="result">
                <h2>识别结果</h2>
                <pre>
                    {% for key, value in result.items() %}
                        <p>{{ key }}: {{ value }}</p>
                    {% endfor %}
                </pre>
            </div>
        {% endif %}
    </div>

    <div class="container">
        <h1>新增交易</h1>
        <form action="/add_transaction" method="post">
            <!-- 科目选择 -->
            <div class="form-group">
                <label for="debit_account">借方科目:</label>
                <!-- 单选按钮组2：支付方式 -->
                <fieldset>
                    <label> 增加
                        <input type="radio" name="direction" value=1 required> 
                    </label>
                    <label> 减少
                        <input type="radio" name="direction" value=-1>
                    </label>
                </fieldset>
                <label>交易详情:
                    <!-- 输入框2：交易详情 -->
                    <input type="text" name="details" value="">
                </label>
                <select name="debit_account" id="debit_account" required>
                    {% for account in accounts %}
                        <option value="{{ account }}">{{ account }}</option>
                    {% endfor %}
                </select>
            </div>
            <div class="form-group">
                <label for="credit_account">贷方科目:</label>
                <select name="credit_account" id="credit_account" required>
                    {% for account in accounts %}
                        <option value="{{ account }}">{{ account }}</option>
                    {% endfor %}
                </select>
            </div>
            <button type="submit">提交</button>
        </form>
    </div>
</body>
</html>